<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="电梯编号" prop="elevatorCode">
        <el-input
          v-model="queryParams.elevatorCode"
          placeholder="请输入电梯编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电梯名称" prop="elevatorName">
        <el-input
          v-model="queryParams.elevatorName"
          placeholder="请输入电梯名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>


      <el-form-item label="出厂编号" prop="factoryNumber">
        <el-input
          v-model="queryParams.factoryNumber"
          placeholder="请输入出厂编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制造日期">
        <el-date-picker
          v-model="daterangeFactoryDate"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="注册代码" prop="deviceNumber">
        <el-input
          v-model="queryParams.deviceNumber"
          placeholder="请输入设备(注册)代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="园区" prop="parkId">
        <el-select clearable v-model="queryParams.parkId" @change="getBuildingList(form.parkId)" placeholder="请选择园区">
          <el-option
            v-for="item in buiParkList"
            :key="item.id"
            :label="item.parkName"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="楼栋" prop="buildingId">
        <el-select
          clearable
          v-model="queryParams.buildingId"
          placeholder="请选择楼栋"
        >
          <el-option
            v-for="item in buildingList"
            :key="item.id"
            :label="item.buildingNum"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="电梯上次年检">
        <el-date-picker
          v-model="daterangeDeviceCheckDate"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="电梯下次年检">
        <el-date-picker
          v-model="daterangeCheckNextDate"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in stateOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <!--<el-form-item label="是否到期" prop="expire">-->
        <!--<el-input-->
          <!--v-model="queryParams.expire"-->
          <!--placeholder="请输入是否到期"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['security:afElevator:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['security:afElevator:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['security:afElevator:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['security:afElevator:export']"
        >导出
        </el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleImport"
          v-hasPermi="['security:afElevator:edit']"
        >导入
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleSetting"
          v-hasPermi="['security:afElevator:set']"
        >配置
        </el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="afElevatorList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="电梯编号" align="center" prop="elevatorCode"/>
      <el-table-column label="电梯名称" align="center" prop="elevatorName"/>
      <!--<el-table-column label="园区" align="center" prop="parkNum"/>-->
      <el-table-column label="楼栋" align="center" prop="buildingNum"/>
      <el-table-column label="单位编号" align="center" prop="dwCode"/>
      <el-table-column label="登记证书" align="center" prop="registrationCode"/>
      <el-table-column label="电梯规格" align="center" prop="elevatorSpecifications"/>
      <el-table-column label="使用单位" align="center" prop="useFactory"/>
      <el-table-column label="制造单位" align="center" prop="factory"/>
      <el-table-column label="出厂编号" align="center" prop="factoryNumber"/>
      <el-table-column label="制造日期" align="center" prop="factoryDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.factoryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="设备(注册)代码" align="center" prop="deviceNumber"/>
      <el-table-column label="额定载重(KG)" align="center" prop="elevatorLoad"/>
      <el-table-column label="额定速度(m/s)" align="center" prop="speed"/>
      <el-table-column label="层/站/门" align="center" prop="plies"/>
      <!--<el-table-column label="安装位置" align="center" prop="location"/>-->
      <el-table-column label="电梯上次年检" align="center" prop="deviceCheckDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deviceCheckDate, '{y}-{m}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电梯下次年检" align="center" prop="checkNextDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.checkNextDate, '{y}-{m}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="限速器上次年检" align="center" prop="speedCheckDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.speedCheckDate, '{y}-{m}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="限速器下次年检" align="center" prop="speedNextDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.speedNextDate, '{y}-{m}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="state" :formatter="stateFormat"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['security:afElevator:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['security:afElevator:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据-->
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>


    <el-dialog :title="setting.title" :visible.sync="setting.open" width="400px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="梯联网ID" prop="elevId">
          <el-input v-model="form.elevId" placeholder="请输入梯联网ID"/>
        </el-form-item>

        <el-form-item label="联网状态" prop="elevStatus">
          <el-select v-model="form.elevStatus" placeholder="请选择状态">
            <el-option
              v-for="dict in statusOptions"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="摄像头ID" prop="cameraId">
          <!--<el-input v-model="form.cameraId" placeholder="请输入摄像头ID"/>-->
          <el-select v-model="form.cameraId" placeholder="请选择摄像头">
            <el-option
              v-for="dict in cameras"
              :key="dict.id"
              :label="dict.channelName"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitSettingForm">确 定</el-button>
        <el-button @click="cancelSetting">取 消</el-button>
      </div>
    </el-dialog>




    <!-- 添加或修改电梯台账对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="资产类型" v-if="!form.id" prop="sysBmId">
          <!--          <BmGenSelect @select="genCode"></BmGenSelect>-->
          <treeselect v-model="form.sysBmId" :options="sysBmTypeOptions" :normalizer="bmNormalizer"
                      placeholder="选择资产类型"/>
        </el-form-item>
        <el-form-item label="电梯名称" prop="elevatorName">
          <el-input v-model="form.elevatorName" placeholder="请输入电梯名称"/>
        </el-form-item>
        <el-form-item label="电梯规格" prop="elevatorSpecifications">
          <el-input v-model="form.elevatorSpecifications" placeholder="请输入电梯规格"/>
        </el-form-item>
        <el-form-item label="园区" prop="parkId">
          <el-select clearable v-model="form.parkId" @change="getBuildingList(form.parkId)" placeholder="请选择园区">
            <el-option
              v-for="item in buiParkList"
              :key="item.id"
              :label="item.parkName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="楼栋" prop="buildingId">
          <el-select
            clearable
            v-model="form.buildingId"
            placeholder="请选择楼栋"
          >
            <el-option
              v-for="item in buildingList"
              :key="item.id"
              :label="item.buildingName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="制造单位" prop="factory">
          <el-input v-model="form.factory" placeholder="请输入制造单位"/>
        </el-form-item>
        <el-form-item label="使用单位" prop="useFactory">
          <el-input v-model="form.useFactory" placeholder="请输入使用单位"/>
        </el-form-item>

        <el-form-item label="出厂编号" prop="factoryNumber">
          <el-input v-model="form.factoryNumber" placeholder="请输入出厂编号"/>
        </el-form-item>
        <el-form-item label="登记证书" prop="registrationCode">
          <el-input v-model="form.registrationCode" placeholder="请输入登记证书"/>
        </el-form-item>

        <el-form-item label="制造日期" prop="factoryDate">
          <el-date-picker clearable size="small"
                          v-model="form.factoryDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择制造日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="设备(注册)代码" prop="deviceNumber">
          <el-input v-model="form.deviceNumber" placeholder="请输入设备(注册)代码"/>
        </el-form-item>
        <el-form-item label="额定载重(KG)" prop="elevatorLoad">
          <el-input v-model="form.elevatorLoad" placeholder="请输入额定载重(KG)"/>
        </el-form-item>
        <el-form-item label="额定速度(m/s)" prop="speed">
          <el-input v-model="form.speed" placeholder="请输入额定速度(m/s)"/>
        </el-form-item>
        <el-form-item label="功率" prop="power">
          <el-input v-model="form.power" placeholder="请输入功率"/>
        </el-form-item>
        <el-form-item label="层/站/门" prop="plies">
          <el-input v-model="form.plies" placeholder="请输入层/站/门"/>
        </el-form-item>
        <el-form-item label="安装位置" prop="location">
          <el-input v-model="form.location" placeholder="请输入安装位置"/>
        </el-form-item>
        <el-form-item label="单位编号" prop="dwCode">
          <el-input v-model="form.dwCode" placeholder="请输入单位编号"/>
        </el-form-item>
        <el-form-item label="限速器编号" prop="speedNumber">
          <el-input v-model="form.speedNumber" placeholder="请输入限速器编号"/>
        </el-form-item>
        <el-form-item label="控制柜编号" prop="ctrNumber">
          <el-input v-model="form.ctrNumber" placeholder="请输入控制柜编号"/>
        </el-form-item>
        <el-form-item label="主机编号" prop="hostNumber">
          <el-input v-model="form.hostNumber" placeholder="请输入主机编号"/>
        </el-form-item>
        <el-form-item label="曳引绳规格" prop="lineSpecifications">
          <el-input v-model="form.lineSpecifications" placeholder="请输入曳引绳规格"/>
        </el-form-item>
        <el-form-item label="电梯上次年检" prop="deviceCheckDate">
          <el-date-picker clearable size="small"
                          v-model="form.deviceCheckDate"
                          type="month"
                          value-format="yyyy-MM-dd"
                          placeholder="选择电梯上次年检">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="电梯下次年检" prop="checkNextDate">
          <el-date-picker clearable size="small"
                          v-model="form.checkNextDate"
                          value-format="yyyy-MM-dd"
                          type="month"
                          placeholder="选择电梯下次年检">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="限速器上次年检" prop="speedCheckDate">
          <el-date-picker clearable size="small"
                          v-model="form.speedCheckDate"
                          type="month"
                          value-format="yyyy-MM-dd"
                          placeholder="选择限速器上次年检">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="限速器下次年检" prop="speedNextDate">
          <el-date-picker clearable size="small"
                          v-model="form.speedNextDate"
                          type="month"
                          value-format="yyyy-MM-dd"
                          placeholder="选择限速器下次年检">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="状态" prop="state">
          <el-select v-model="form.state" placeholder="请选择状态">
            <el-option
              v-for="dict in stateOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listAfElevator,
  getAfElevator,
  delAfElevator,
  addAfElevator,
  updateAfElevator,
  updateAfElevatorConfig,
  settingAfElevator
} from '@/api/smartParks/security/securityElevator'
import { listBuiPark } from '@/api/parkAssets/enterCommunity'
import { listBuiBuilding } from '@/api/parkAssets/building'
import { getToken } from '@/utils/auth'
import {listAfDeviceCamera} from '@/api/smartParks/security/afDeviceCamera'

export default {
  name: 'AfElevator',
  components: {},
  data() {
    return {
      statusOptions: [{
        value: '0',
        label: '未联网'
      }, {
        value: '1',
        label: '已联网'
      }],


      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 电梯台账表格数据
      afElevatorList: [],
      cameras: [],
      buiParkList: [],
      buildingList: [],
      parkList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 制造日期时间范围
      daterangeFactoryDate: [],
      // 电梯上次年检时间范围
      daterangeDeviceCheckDate: [],
      // 电梯下次年检时间范围
      daterangeCheckNextDate: [],
      // 限速器上次年检时间范围
      daterangeSpeedCheckDate: [],
      // 限速器下次年检时间范围
      daterangeSpeedNextDate: [],
      // 状态字典
      stateOptions: [],
      setting:{
        title: '',
        open:false,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: '',
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/security/afElevator/importData'
      },
      // 查询参数
      sysBmTypeOptions: this.$store.state.permission.sysBmTree,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        elevatorCode: null,
        elevatorName: null,
        elevatorSpecifications: null,
        useFactory: null,
        factory: null,
        factoryNumber: null,
        factoryDate: null,
        deviceNumber: null,
        parkId: null,
        buildingId: null,
        deviceCheckDate: null,
        checkNextDate: null,
        speedCheckDate: null,
        speedNextDate: null,
        state: null,
        expire: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        factory: [
          { required: true, message: '生产厂家不能为空', trigger: 'blur' }
        ],
        sysBmId: [
          { required: true, message: '资产类型不能为空', trigger: 'blur' }
        ],
        elevatorCode: [
          { required: true, message: '电梯编号不能为空', trigger: 'blur' }
        ],
        parkId: [
          { required: true, message: '园区不能为空', trigger: 'blur' }
        ],
        buildingId: [
          { required: true, message: '楼栋不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
    this.getList()
    this.getDicts('device_work_state').then(response => {
      this.stateOptions = response.data
    })
    listBuiPark().then((response) => {
      this.buiParkList = response.rows
    })
    listBuiBuilding().then((response) =>{
      this.buildingList = response.rows;
    })
    listAfDeviceCamera().then((response) =>{
      this.cameras = response.rows;
    })
  },
  methods: {
    /** 导入按钮操作 */


    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = '编码导入'
      this.upload.open = true
    },

    // genCode(item) {
    //   console.log('item', item)
    //   this.form.sysBmId = item.bmId
    // },
    //得到楼栋
    getBuildingList(value) {
      //this.form.buildingId = ''
      //this.$set(this.form, "buildingId", "");
      this.buildingList=[];
      listBuiBuilding({ parkId: value }).then((response) =>{
        this.buildingList = response.rows;
      })
    },

    /** 查询电梯台账列表 */
    getList() {
      this.loading = true
      this.queryParams.params = {}
      if (null != this.daterangeFactoryDate && '' != this.daterangeFactoryDate) {
        this.queryParams.params['beginFactoryDate'] = this.daterangeFactoryDate[0]
        this.queryParams.params['endFactoryDate'] = this.daterangeFactoryDate[1]
      }
      if (null != this.daterangeDeviceCheckDate && '' != this.daterangeDeviceCheckDate) {
        this.queryParams.params['beginDeviceCheckDate'] = this.daterangeDeviceCheckDate[0]
        this.queryParams.params['endDeviceCheckDate'] = this.daterangeDeviceCheckDate[1]
      }
      if (null != this.daterangeCheckNextDate && '' != this.daterangeCheckNextDate) {
        this.queryParams.params['beginCheckNextDate'] = this.daterangeCheckNextDate[0]
        this.queryParams.params['endCheckNextDate'] = this.daterangeCheckNextDate[1]
      }
      if (null != this.daterangeSpeedCheckDate && '' != this.daterangeSpeedCheckDate) {
        this.queryParams.params['beginSpeedCheckDate'] = this.daterangeSpeedCheckDate[0]
        this.queryParams.params['endSpeedCheckDate'] = this.daterangeSpeedCheckDate[1]
      }
      if (null != this.daterangeSpeedNextDate && '' != this.daterangeSpeedNextDate) {
        this.queryParams.params['beginSpeedNextDate'] = this.daterangeSpeedNextDate[0]
        this.queryParams.params['endSpeedNextDate'] = this.daterangeSpeedNextDate[1]
      }
      console.log(this.queryParams);
      listAfElevator(this.queryParams).then(response => {
        this.afElevatorList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 状态字典翻译
    stateFormat(row, column) {
      return this.selectDictLabel(this.stateOptions, row.state)
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    cancelSetting(){
      this.setting.open = false
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        registrationCode: null,
        sysBmId: null,
        elevatorCode: null,
        elevatorName: null,
        elevatorSpecifications: null,
        useFactory: null,
        factory: null,
        factoryNumber: null,
        factoryDate: null,
        deviceNumber: null,
        elevatorLoad: null,
        speed: null,
        power: null,
        plies: null,
        parkId: null,
        buildingId: null,
        location: null,
        dwCode: null,
        speedNumber: null,
        ctrNumber: null,
        hostNumber: null,
        lineSpecifications: null,
        deviceCheckDate: null,
        checkNextDate: null,
        speedCheckDate: null,
        speedNextDate: null,
        updateBy: null,
        updateTime: null,
        createTime: null,
        delFlag: null,
        tenantId: null,
        remark: null,
        propertyDesc: null,
        state: null,
        createBy: null,
        elevId: null,
        elevStatus: null,
        expire: null
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeFactoryDate = []
      this.daterangeDeviceCheckDate = []
      this.daterangeCheckNextDate = []
      this.daterangeSpeedCheckDate = []
      this.daterangeSpeedNextDate = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加电梯台账'
    },

    submitSettingForm(){
      this.$refs['form'].validate(valid => {

          if (this.form.id != null) {
            updateAfElevatorConfig(this.form).then(response => {
              this.msgSuccess('修改成功')
              this.setting.open = false
              this.getList()
            })
          }

          // if (this.form.id != null) {
          //   var req = {
          //     id: this.form.id,
          //     elevId: this.form.elevId,
          //     elevStatus: this.form.elevStatus
          //   }
          //   settingAfElevator(req).then(response => {
          //     this.msgSuccess('修改成功')
          //     this.setting.open = false
          //     this.getList()
          //   })
          // }
      })
    },

    handleSetting(row){
      this.reset();
      const id = row.id || this.ids
      getAfElevator(id).then(response => {
        this.form = response.data
        this.setting.open = true
        this.setting.title = '配置梯联网信息'
      })
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getAfElevator(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = '修改电梯台账'
      })

    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateAfElevator(this.form).then(response => {
              this.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            addAfElevator(this.form).then(response => {
              this.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$confirm('是否确认删除电梯台账编号为"' + ids + '"的数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return delAfElevator(ids)
      }).then(() => {
        this.getList()
        this.msgSuccess('删除成功')
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('security/afElevator/export', {
        ...this.queryParams
      }, `security_afElevator.xlsx`)
    },

    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true
    }
    ,
// 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false
      this.upload.isUploading = false
      this.$refs.upload.clearFiles()
      this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
      this.getList()
    },

// 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit()
      this.upload.open = false

    }
  }
}
</script>
